<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla view library
jimport('joomla.application.component.view');
 
class CouponsViewShops extends JView
{
    protected $pagination;
    protected $items;
    
    private $users=array();
    
    // Overwriting JView display method
    function display($tpl = null) {
        
            JToolBarHelper::title(   JText::_( 'COM_COUPONS_SHOP_MANAGER' ).": ".JText::_( 'COM_COUPONS_COUPONS' ), 'generic.png' );
            JToolBarHelper::addNewX('shop.add');
            JToolBarHelper::editListX('shop.edit');
            JToolBarHelper::divider();
            JToolBarHelper::deleteList('','shops.remove');

            $this->pagination = $this->get('Pagination');
            $this->items = $this->get('Items');

            // Check for errors.
            if (count($errors = $this->get('Errors'))) 
            {
                    JError::raiseError(500, implode('<br />', $errors));
                    return false;
            }

            parent::display($tpl);
    }
    
    public function getUser($userId)
    {
        if(array_key_exists($userId, $this->users))
                return $this->users[$userId];
        $model = $this->getModel();
        $user = JUser::getInstance($userId);
        $this->users[$userId] = $user->username;
        return $user->username;
    }
}
?>